
/**
 * User: wanghe
 * Date: 13-11-12
 * Time: 下午4:49
 * UUIDGenerator.
 */
Object.defineProperty(exports, "__esModule", { value: true });
var k1 = new Array(32);
var k2 = new Array(32);
var l = 4;
var v = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
var ELEMENTS = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
var length = ELEMENTS.length;
var prefix = '';
function inc(p) {
    if (p >= l)
        ++l;
    v[p] = v[p] + 1;
    if (v[p] >= ELEMENTS.length) {
        v[p] = 0;
        inc(p + 1);
    }
}
function init() {
    for (var i = 0; i < k1.length; i++) {
        k1[i] = k2[i] = i;
    }
    for (var i = 0; i < k1.length; i++) {
        k1[i] = ((Math.random() * 6173)) % k1.length;
    }
    for (var i = k2.length - 1; i >= 0; i--) {
        var a = ((Math.random() * 6173)) % k2.length;
        var tmp = k2[i];
        k2[i] = k2[a];
        k2[a] = tmp;
    }
    var n = ((new Date().getTime() / 1000) % 100000000);
    do {
        prefix = ELEMENTS.charAt(n % length) + prefix;
        n /= length;
    } while (n >= length);
}
function next() {
    inc(0);
    var b = (Math.random() * 6173) % ELEMENTS.length;
    var t = '' + ELEMENTS.charAt(b);
    b = k2[b % k2.length] ^ ((b >>> 1) ^ (b << 9));
    b = k1[b % k1.length] ^ ((b >>> 1) ^ (b << 8));
    b = k2[b % k2.length] ^ ((b >>> 1) ^ (b << 7));
    for (var i = 0; i < l; i++) {
        var a = v[i];
        a = (a + k1[Math.abs(b) % k1.length]) % ELEMENTS.length;
        t += ELEMENTS.charAt(a);
        b = k2[a % k2.length] ^ ((b >>> 1) ^ (b << 9));
    }
    return prefix + t;
}
init();
exports.default = {
    next: next
};


//# sourceURL=webpack://MTDX/./src/core/utils/uuid.ts?